package com.phrp.controller;

import com.phrp.entity.vo.InspectionSearchDataVO;
import com.phrp.entity.InspectionRecord;
import com.phrp.service.InspectionRecordService;
import com.phrp.util.returnResult.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ssc
 * @since 2024-05-03
 */
@RestController
@RequestMapping("/inspection")
public class InspectionRecordController {

    @Autowired
    private InspectionRecordService inspectionRecordService;

    /**
     * 根据条件搜索数据
     *
     * @param searchData
     * @return
     */
    @PostMapping(value = "getSearchData")
    public ResponseResult getSearchData(@RequestBody InspectionSearchDataVO searchData) {
        return inspectionRecordService.getSearchData(searchData);
    }

    /**
     * 新增巡查数据
     * @param mUuid
     * @param hUuid
     * @param inspectionTime
     * @return
     */
    @GetMapping(value = "insertInspection")
    public ResponseResult insertInspection(@RequestParam("muuid") String mUuid, @RequestParam("huuid") String hUuid,
                                           @RequestParam("inspectionTime") String inspectionTime) {
        return inspectionRecordService.insertInspection(mUuid,hUuid,inspectionTime);
    }

    /**
     * 编辑巡查信息
     * @param inspection
     * @return
     */
    @PostMapping(value = "editInspection")
    public ResponseResult editInspection(@RequestBody InspectionRecord inspection){
        return inspectionRecordService.editInspection(inspection);
    }

    /**
     * 删除巡查数据
     * @param map
     * @return
     */
    @PostMapping(value = "deleteInspection")
    public ResponseResult deleteInspection(@RequestBody HashMap<String,List<String>> map){
        return inspectionRecordService.deleteInspection(map.get("ids"),map.get("mUuids"));
    }

}
